package com.deng.eventflow.core.tmf;

import com.deng.eventflow.core.PubliclyStateful;
import com.deng.eventflow.core.UniformProcessor;

public class Passthrough extends UniformProcessor implements PubliclyStateful {
    public Passthrough(int arity)
    {
        super(arity, arity);
    }

    public Passthrough()
    {
        this(1);
    }

    @Override
    protected boolean compute(Object[] inputs, Object[] outputs)
    {
        for (int i = 0; i < inputs.length; i++)
        {
            outputs[i] = inputs[i];
            if (m_eventTracker != null)
            {
                m_eventTracker.associateToInput(getId(), i, m_inputCount, i, m_outputCount);
            }
        }
        m_inputCount++;
        m_outputCount++;
        return true;
    }

    @Override
    public Passthrough duplicate(boolean with_state)
    {
        return new Passthrough(getInputArity());
    }

    /**
     * @since 0.10.2
     */
    public Object printState()
    {
        return getInputArity();
    }

    /**
     * @since 0.10.2
     */
    @Override
    public Passthrough readState(Object o)
    {
        return new Passthrough(((Number) o).intValue());
    }

    @Override
    public Object getState()
    {
        return 0;
    }

}
